/**************************************************************************************
 *                    .::::.
 *                  .::::::::.
 *                 ::::::::::: 
 *             ..:::::::::::'
 *           '::::::::::::'
 *             .::::::::::
 *        '::::::::::::::..
 *             ..::::::::::::.
 *           ``::::::::::::::::
 *            ::::``:::::::::'        .:::.
 *           ::::'   ':::::'       .::::::::.
 *         .::::'      ::::     .:::::::'::::.
 *        .:::'       :::::  .:::::::::' ':::::.
 *       .::'        :::::.:::::::::'      ':::::.
 *      .::'         ::::::::::::::'         ``::::.
 *  ...:::           ::::::::::::'              ``::.
 * ```` ':.          ':::::::::'                  ::::..
 *                    '.:::::'                    ':'````..
 * -----------------------------  地图页面 摩比秀 
 * -------------------------  yaohuitao@100tal.com
 * --------------------- 20180906
 * ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀🌙｀ヽヽ｀ヽ、ヽ｀ヽ｀、ヽ｀｀、ヽ 
 * 、｀｀、 ｀、ヽ｀ 、、ヽ｀｀、ヽ、｀｀、、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀
 * 、 、 ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀｀ヽ、💃｀ヽ🏃、、🚶｀🚶🚶ヽ｀、
***************************************************************************************/
class Map extends eui.Component {
    public constructor() {
		super();
	}

    protected childrenCreated():void
	{
		super.childrenCreated();
        this.initMap();
    }
    protected partRemoved(partName: string, instance: any):void
	{
        console.log(partName);
		super.partRemoved(partName,instance);
	}

    private goHomeBtn:eui.Button;
    private lookForOtherBtn:eui.Button;

    private async initMap() {
        Utils.setStage(this);

        let loading = new Loading();
        this.addChild(loading)
        setTimeout(()=>{
            loading.removeLoading();
        },2000)

        let msg = new MessageBox("我的天啊2",()=>{
            
        },{
            showCancelButton:true,
            maskAlpha:0.1,
            sureBtnText:"gogogo"
        })
        this.addChild(msg);
        
        //请求
        RequestFn.instance.Ajax("rest/sys/time",(res)=>{
            console.log(res);
            this.goHomeBtn.scaleX = this.goHomeBtn.scaleY =0.7;
        },()=>{});

        this.lookForOtherBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onGohomeFn, this);

    }
    private onGohomeFn(){
        console.log("goHome");
        this.addChild(new Toast("哈哈哈",2000))
        //this.endListener();
        //SceneManager.goSceneByName("home");
    }

    /**
     * 场景切换前结束监听
    */
    private endListener(){
        this.goHomeBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onGohomeFn, this);
    }
}